package cn.smile;

import org.redisson.Redisson;
import org.redisson.api.RedissonClient;
import org.redisson.config.Config;
import org.redisson.config.SentinelServersConfig;
import org.redisson.config.SingleServerConfig;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;
import org.springframework.data.redis.connection.RedisStandaloneConfiguration;

@SpringBootApplication
public class DistributedLockApplication {

    public static void main(String[] args) {
        SpringApplication.run(DistributedLockApplication.class, args);
    }


    @Bean
    public Redisson redisson(){

        Config config=new Config();
        //哨兵
//        SentinelServersConfig sentinelServersConfig = config.useSentinelServers();
//        sentinelServersConfig.setDatabase(0);
//        sentinelServersConfig.addSentinelAddress("redis://175.24.228.237:6379","redis://47.105.164.51:36379");
//        sentinelServersConfig.setPassword("MaoSuyu123123");
//        sentinelServersConfig.setMasterName("Master");

        //单机
        SingleServerConfig singleServerConfig = config.useSingleServer();
        singleServerConfig.setAddress("redis://175.24.228.237:6379");
        singleServerConfig.setPassword("maomao");
        return (Redisson)Redisson.create(config);
    }

}
